package cn.kgc.service;

import cn.kgc.dao.WXWdictionaryDao;
import cn.kgc.pojo.AppCategory;
import cn.kgc.pojo.AppInfo;
import cn.kgc.pojo.DataDictionary;
import cn.kgc.pojo.WXWAppInfo;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * @author: wang
 * @date: 2022/1/4
 * @description:
 */
@Service
public class WXWdictionaryServiceImpl implements WXWdictionaryService{
    @Resource
    private WXWdictionaryDao wxWdictionaryDao;
    @Override
    public List<DataDictionary> selApp() {
        return wxWdictionaryDao.selApp();
    }

    @Override
    public List<DataDictionary> selPing() {
        return wxWdictionaryDao.selPing();
    }

    @Override
    public List<AppCategory> selYi() {
        return wxWdictionaryDao.selYi();
    }

    @Override
    public List<AppCategory> selEr(Integer id) {
        return wxWdictionaryDao.selEr(id);
    }

    @Override
    public List<AppCategory> selSan(Integer id) {
        return wxWdictionaryDao.selSan(id);
    }

    @Override
    public Page<WXWAppInfo> selFen(HashMap<String, Object> map) {
        return wxWdictionaryDao.selFen(map);
    }

    @Override
    public boolean updInfoShang(Integer id) {
        if (wxWdictionaryDao.updInfoShang(id)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean updInfoXia(Integer id) {
        if (wxWdictionaryDao.updInfoXia(id)>0){
            return true;
        }
        return false;
    }

    @Transactional
    @Override
    public boolean del(Integer id) {
        int i = wxWdictionaryDao.delInfo(id);
        int j = wxWdictionaryDao.delVer(id);
        if (i>-1&&j>-1){
            return true;
        }else{
            throw new RuntimeException();
        }
    }

    @Override
    public AppInfo selById(Integer id) {
        return wxWdictionaryDao.selById(id);
    }

    @Override
    public boolean updaInfo(AppInfo appInfo) {
        if (wxWdictionaryDao.updaInfo(appInfo)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean addInfo(AppInfo appInfo) {
        if (wxWdictionaryDao.addInfo(appInfo)>0){
            return true;
        }
        return false;
    }
}
